<template>
	<view class="storeInfo p-20">
		<view class="bg-white p-20 radius-md text-sm" v-if="info">
			<view class="flex gap-10">
				<u-image :src="info.logo" width="200rpx" height="200rpx"></u-image>
				<view class="flex-1">
					<view class="text-lg flex jus-b">
						<text class="line-two">{{ info.store_name || '' }}</text>
						<text>{{ info.status == 1 ? '营业中' : '歇业中' }}</text>
					</view>
					<view class="text-sm flex jus-b mt-10">
						<text class="flex-1">{{ info.cate_name || '' }}</text>
						<view class="flex ali-c">
							<u-icon name="star-fill" size="16" color="yellow"></u-icon>
							<text class="ml-10 text-black">{{ info.merch_score || 0 }}</text>
						</view>
					</view>
					<view class="mt-10"> {{ info.address }} </view>
					<view class="mt-10">{{ info.status==1?'通过':'禁用' }}</view>
				</view>
			</view>
			<view class="flex mt-20 gap-10 flex-end">
				<!-- <view class="flex" style="width: 150rpx;">
					<u-button :type="info.status==1?'':'primary'" text="打烊" shape="circle" size="small"></u-button>
				</view> -->
				<view class="flex" style="width: 150rpx;">
					<u-button type="primary" @click="tovoucherscan()" text="代金券核销" shape="circle"
						size="small"></u-button>
				</view>
				<view class="flex" style="width: 150rpx;">
					<u-button type="primary" @click="toscan()" text="扫码核销" shape="circle" size="small"></u-button>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		props: {
			info: {
				type: Object,
				default: () => null
			}
		},
		data() {
			return {}
		},
		methods: {
			//扫码
			toscan() {
				// 允许从相机和相册扫码
				let that = this
				uni.scanCode({
					success: function(res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						that.$http({
							url: 'api/merch/scanCode',
							data: {
								code_data: res.result
							}
						}).then(es => {
							uni.showToast({
								title: es.msg,
								icon: 'none'
							})
						})
						// uni.navigateTo({
						// 	url: res.result
						// })
					}
				});
			},
			tovoucherscan() {
				// 允许从相机和相册扫码
				let that = this
				uni.scanCode({
					success: function(res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						that.$http({
							url: 'api/merch/scanVoucherCode',
							data: {
								code_data: res.result
							}
						}).then(es => {
							uni.showToast({
								title: es.msg,
								icon: 'none'
							})
						})
						// uni.navigateTo({
						// 	url: res.result
						// })
					}
				});
			},
		}
	}
</script>
<style lang="scss">
	.storeInfo {
		position: relative;
	}
</style>